#!/usr/bin/Rscript --vanilla
# this script downloads stock data from finance.yahoo.com
# to determine at what time the data of the previois day becomes 
# available

suppressPackageStartupMessages(library(quantmod))
options("getSymbols.warning4.0"=FALSE)

print (paste("run at", format(date())))

symbols <- c("AAPL", "SLW", "ABX")

for (symbol in symbols) {
  TS <- getSymbols(symbol, from="2015-01-01", auto.assign=FALSE)
  if (is.xts(TS) & nrow(TS)>0) {
    print (paste("...", index(last(TS)), "for", symbol))
  } else {
    print (paste("...failed to retrieve", symbol))
  }
}